package com.sunyard.utils.msg;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MD5Utils {
    public static String createSign(String characterEncoding, Map<String, String> parameters) {
        StringBuffer sb = new StringBuffer();
        StringBuffer sbkey = new StringBuffer();
        Set es = parameters.entrySet();  //所有参与传参的参数按照accsii排序（升序）
        Iterator it = es.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            String k = (String) entry.getKey();
            Object v = entry.getValue();
            //空值不传递，不参与签名组串
            if (null != v && !"".equals(v)) {
                sb.append(k + "=" + v + "&");
                sbkey.append(k + "=" + v + "&");
            }
        }
        System.out.println("字符串:" + sbkey.toString().substring(0, sb.length() - 1));
        return sb.toString().substring(0, sb.length() - 1);
    }
}
